library(tidyverse)
This is the import process
library(dplyr)
library(ggplot2)
simulated_patient_data %>%
filter(start >= "1950-11-10 22:54:30" & start <= "2020-12-04 22:58:46") %>%
filter(marital %in% "S" | is.na(marital)) %>%
filter(patient_age >= 57L & patient_age <=
111L) %>%
ggplot() +
aes(x = race, fill = gender) +
geom_bar() +
scale_fill_hue() +
theme_minimal()
This is the data viz
simulated_patient_data %>%
filter(start >= "1950-11-10 22:54:30" & start <= "2020-12-04 22:58:46") %>%
filter(marital %in% "S" | is.na(marital)) %>%
filter(patient_age >= 57L & patient_age <=
111L) %>%
ggplot() +
aes(x = race, fill = gender) +
geom_bar() +
scale_fill_hue() +
theme_minimal()
Error in simulated_patient_data %>% filter(start >= "1950-11-10 22:54:30" & :
could not find function "%>%"
Interactive data viz
library(ggplot2)
library(plotly)
package ‘plotly’ was built under R version 4.0.3Registered S3 method overwritten by 'data.table':
method from
print.data.table
Registered S3 method overwritten by 'htmlwidgets':
method from
print.htmlwidget tools:rstudio
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
p <- ggplot(data = diamonds, aes(x = cut, fill = clarity)) +
geom_bar(position = "dodge")
ggplotly(p)